import request from '@/config/axios'

// PI 任务单 VO
export interface AssignmentVO {
  id: number // 编号
  jobCode: string // 巡检单编号
  jobStatus: number // 任务单状态
  jobDate: Date // 任务单日期
}

// PI 任务单 API
export const AssignmentApi = {
  // 查询PI 任务单分页
  getAssignmentPage: async (params: any) => {
    return await request.get({ url: `/pi/assignment/page`, params })
  },

  // 查询PI 任务单详情
  getAssignment: async (id: number) => {
    return await request.get({ url: `/pi/assignment/get?id=` + id })
  },

  // 新增PI 任务单
  createAssignment: async (data: AssignmentVO) => {
    return await request.post({ url: `/pi/assignment/create`, data })
  },

  // 修改PI 任务单
  updateAssignment: async (data: AssignmentVO) => {
    return await request.put({ url: `/pi/assignment/update`, data })
  },

  // 删除PI 任务单
  deleteAssignment: async (id: number) => {
    return await request.delete({ url: `/pi/assignment/delete?id=` + id })
  },

  // 导出PI 任务单 Excel
  exportAssignment: async (params) => {
    return await request.download({ url: `/pi/assignment/export-excel`, params })
  },

// ==================== 子表（PI 任务单明细） ====================

  // 获得PI 任务单明细列表
  getAssignmentDetailListByJobId: async (jobId) => {
    return await request.get({ url: `/pi/assignment/assignment-detail/list-by-job-id?jobId=` + jobId })
  },
}